def cow_count(n):
    f = [0] * 55
    f[1] = 1
    f[2] = 2
    f[3] = 3
    for i in range(4, 55):
        f[i] = f[i-1] + f[i-3]
    return f[n]
while True:
    n = int(input("请输入年份 n（0<n<55），输入 0 结束："))
    if n == 0:
        print("程序结束。")
        break
    if n <= 0 or n >= 55:
        print("输入无效，请重新输入。")
        continue
    print(cow_count(n))
